{% extends 'layouts/master-page' %}
{% block title %}{{cve['id']}} - {{cve['summary'][:100]}}{% endblock %}
{% block head %}
  <!-- css -->
  <link href="/static/css/custom/cve.css" rel="stylesheet" />
  <!-- javascript -->
  {% if not minimal %}
    <script type="text/javascript" src="/static/js/ZeroClipboard.min.js"></script>
    <script type="text/javascript" src="/static/js/custom/cve.js"></script>
  {% endif %}
{% endblock %}
{% block content %}
  <input type="hidden" id="_cveID" value="{{cve['id']}}">
  <!-- breadcrumb -->
  <ol class="breadcrumb">
    <li><a href="/">CVE-Search</a></li>
    <li class="active">{{cve['id']}}</li>
  </ol>
  <!-- CVE -->
  <table id="cveInfo" class="table table-hover table-striped">
    <tbody>
      <tr>
        <td class="warning">ID</td>
        <td class="info">
          {{ cve['id'] }}
          {% if not minimal %}
            <table id="actions">
              <tr>
                <td>Actions</td>
                <td id="cve_actions">&nbsp;loading...</td>
              </tr>
            </table>
          {% endif %}
        </td>
      </tr>
      <tr>
        <td class="warning">Summary</td>
        <td class="info">{{ cve['summary'] }}</td>
      </tr>
      <tr>
        <td class="warning">References</td>
        <td>
          <div class="semiCollapsed colfield">
            <ul class="block">
              {% for ref in cve['references'] %}
                <li> <a href="{{ ref }}" target="_blank">{{ ref }}</a> </li>
              {% endfor %}
            </ul>
          </div>
        </td>
      </tr>
      <tr>
        <td class="warning">Vulnerable Configurations</td>
        <td>
          <div class="colfield semiCollapsed">
            <ul class="block">
              {% for vulconf in cve['vulnerable_configuration'] %}
                <li
                  {% if vulconf['list'] == 'white' %}
                    class="whitelisted"
                  {% elif vulconf['list'] == 'black' %}
                    class="blacklisted"
                  {% endif %}
                  title="{{ vulconf['id'] }} matches {{ vulconf['match'] }}">
                  <span data-toggle="collapse" data-target="#v{{ loop.index }}" > {{ vulconf['title'] }}</span>
                  <div id="v{{ loop.index }}" class="collapse">{{ vulconf['id'] }}</div>
                </li>
              {% endfor %}
            </ul>
          </div>
        </td>
      </tr>
      <tr>
        <td class="warning">CVSS</td>
        <td class="info">
          <table class="invisiTable">
            <tr><td><b>Base:          </b></td><td>{{ cve['cvss'] }} {% if 'cvss-time' in cve %}(as of {{ cve['cvss-time'].strftime('%d-%m-%Y - %H:%M') }}){% endif %}</td></tr>
            <tr><td><b>Impact:        </b></td><td>{{ cve['impactCVSS'] }}</td></tr>
            <tr><td><b>Exploitability:</b></td><td>{{ cve['exploitCVSS'] }}</td></tr>
          </table>
        </td>
      </tr>
      {% if 'cwe' in cve%}
        {% if cve['cwe'] != 'Unknown' %}
          <tr>
            <td class="warning">CWE</td>
            <td class="info"><a href="/cwe/{{ cve['cwe'].split('-')[1] }}" target="_blank">{{ cve['cwe'] }}</a></td>
          </tr>
        {% endif %}
      {% endif %}
      {% if 'capec' in cve%}
        {% if cve['cwe']|length != 0 %}
          <tr>
            <td class="warning">CAPEC</td>
            <td class="info">
              <div class="colfield semiCollapsed">
                <ul class="block">
                  {% for c in cve['capec'] %}
                    <li>
                      <a href="/capec/{{c['id']}}"><span class="glyphicon glyphicon-info-sign"></span></a>
                      <span data-toggle="collapse" data-target="#c{{ loop.index }}"> {{c['name']}} </span>
                      <div id="c{{ loop.index }}" class="collapse"> {{c['summary']}} </div>
                    </li>
                  {% endfor %}
                </ul>
              </div>
            </td>
          </tr>
        {% endif %}
      {% endif %}
      {% if 'access' in cve %}
        <tr>
          <td class="warning">Access</td>
          <td class="info">
            <table class="table table-hover table-bordered cve-info table-even">
              <thead><tr class="warning"><td>Vector</td><td>Complexity</td><td>Authentication</td></tr></thead>
              <tr>
                <td>{{cve['access']['vector']}}</td>
                <td>{{cve['access']['complexity']}}</td>
                <td>{{cve['access']['authentication']}}</td>
              </tr>
            </table>
          </td>
        </tr>
      {% endif %}
      {% if 'impact' in cve %}
        <tr>
          <td class="warning">Impact</td>
          <td class="info">
            <table class="table table-hover table-bordered cve-info">
              <thead><tr class="warning"><td>Confidentiality</td><td>Integrity</td><td>Availability</td></tr></thead>
              <tr>
                <td class="impact-{{cve['impact']['confidentiality']|lower}}">{{cve['impact']['confidentiality']}}</td>
                <td class="impact-{{cve['impact']['integrity']|lower}}">{{cve['impact']['integrity']}}</td>
                <td class="impact-{{cve['impact']['availability']|lower}}">{{cve['impact']['availability']}}</td>
              </tr>
            </table>
          </td>
        </tr>
      {% endif %}
      {% set keytype = ['vulnerable_configuration_cpe_2_2','impactCVSS','exploitCVSS' ,'cvss', 'capec', 'access', 'impact', 'cvss-time', 'Modified', 'Published', 'summary', 'vulnerable_configuration', 'references', '_id', 'id', 'last-modified', 'ranking', 'cwe', 'vulnerable_product', 'assigner'] %}
      {% for key, value in cve|dictsort %}
        {% if not key in keytype %}
          <tr>
            <td class="warning">{{ key }}
              <span class="badge"><a href="https://github.com/CVE-Search/VIA4CVE/" target="_blank">via4</a></span>
            </td>
            <td class="info">
                {{ JSON2HTMLTable(value, key)|safe }}
            </td>
          </tr>
        {% endif %}
      {% endfor %}
      {% for plugin in plugins %}
        <tr>
          <td class="warning">{{plugin['title']}} <span class="badge">plugin</span></td>
          <td class="info"><div class="colfield semiCollapsed">  {{plugin['data']|safe}} </div></td>
        </tr>
      {% endfor %}
      <tr>
        <td class="warning">Last major update</td>
        <td class="info">{{ cve['Modified'].strftime('%d-%m-%Y - %H:%M') }}</td>
      </tr>
      <tr>
        <td class="warning">Published</td>
        <td class="info">{{ cve['Published'].strftime('%d-%m-%Y - %H:%M') }}</td>
      </tr>
      {% if 'last-modified' in cve%}
        <tr>
          <td class="warning">Last modified</td>
          <td class="info">{{ cve['last-modified'].strftime('%d-%m-%Y - %H:%M') }}</td>
        </tr>
      {% endif %}
    </tbody>
  </table>
{% endblock %}
